import { IPSModelSortable } from '../ipsmodel-sortable';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEAction } from '../dataentity/action/ipsdeaction';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSDEActionTestCase } from './ipsdeaction-test-case';
import { IPSDEFVRTestCase } from './ipsdefvrtest-case';
import { IPSSysTestCase } from './ipssys-test-case';
import { IPSSysTestCaseAssert } from './ipssys-test-case-assert';
import { IPSSysTestCaseInput } from './ipssys-test-case-input';
import { IPSSysTestData } from './ipssys-test-data';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysTestCaseImpl extends PSModelObjectImpl implements IPSSysTestCase, IPSDEFVRTestCase, IPSDEActionTestCase, IPSModelSortable {
  get assertExceptionData(): string {
    return this.M.assertExceptionData;
  }

  get assertExceptionData2(): string {
    return this.M.assertExceptionData2;
  }

  get assertExceptionName(): string {
    return this.M.assertExceptionName;
  }

  get assertType(): 'RESULT' | 'EXCEPTION' | 'DATAEXISTS' | 'NOEXCEPTION' | 'CUSTOMCODE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.assertType;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psdeaction: IPSDEAction | null = null;

  getPSDEAction(): IPSDEAction | null {
    if (this.psdeaction != null) return this.psdeaction;
    const value = this.M.getPSDEAction;
    if (value == null) {
      return null;
    }
    this.psdeaction = this.getPSDataEntityMust().findPSDEAction(value);
    return this.psdeaction;
  }

  get psDEAction(): IPSDEAction | null {
    return this.getPSDEAction();
  }

  getPSDEActionMust(): IPSDEAction {
    const value = this.getPSDEAction();
    if (value == null) {
      throw new Error('未指定测试实体行为');
    }
    return value;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    this.psdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定相关实体属性');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定测试实体对象');
    }
    return value;
  }

  protected pssystestcaseasserts: IPSSysTestCaseAssert[] | null = null;

  getPSSysTestCaseAsserts(): IPSSysTestCaseAssert[] | null {
    if (this.pssystestcaseasserts == null) {
      this.pssystestcaseasserts = this.fillChildListModel(this.M.getPSSysTestCaseAsserts, 'testing.IPSSysTestCaseAssert') as IPSSysTestCaseAssert[];
    }
    return this.pssystestcaseasserts;
  }

  get psSysTestCaseAsserts(): IPSSysTestCaseAssert[] | null {
    return this.getPSSysTestCaseAsserts();
  }

  findPSSysTestCaseAssert(objKey: any): IPSSysTestCaseAssert | null {
    return this.getPSModel5('testing.IPSSysTestCaseAssert', this.getPSSysTestCaseAsserts(), objKey) as IPSSysTestCaseAssert;
  }

  protected pssystestcaseinputs: IPSSysTestCaseInput[] | null = null;

  getPSSysTestCaseInputs(): IPSSysTestCaseInput[] | null {
    if (this.pssystestcaseinputs == null) {
      this.pssystestcaseinputs = this.fillChildListModel(this.M.getPSSysTestCaseInputs, 'testing.IPSSysTestCaseInput') as IPSSysTestCaseInput[];
    }
    return this.pssystestcaseinputs;
  }

  get psSysTestCaseInputs(): IPSSysTestCaseInput[] | null {
    return this.getPSSysTestCaseInputs();
  }

  findPSSysTestCaseInput(objKey: any): IPSSysTestCaseInput | null {
    return this.getPSModel5('testing.IPSSysTestCaseInput', this.getPSSysTestCaseInputs(), objKey) as IPSSysTestCaseInput;
  }

  protected pssystestdata: IPSSysTestData | null = null;

  getPSSysTestData(): IPSSysTestData | null {
    if (this.pssystestdata != null) return this.pssystestdata;
    const value = this.M.getPSSysTestData;
    if (value == null) {
      return null;
    }
    this.pssystestdata = this.getPSModel4('testing.IPSSysTestData', value, 'getPSSysTestData') as IPSSysTestData;
    return this.pssystestdata;
  }

  get psSysTestData(): IPSSysTestData | null {
    return this.getPSSysTestData();
  }

  getPSSysTestDataMust(): IPSSysTestData {
    const value = this.getPSSysTestData();
    if (value == null) {
      throw new Error('未指定测试数据');
    }
    return value;
  }

  get testCaseSN(): string {
    return this.M.testCaseSN;
  }

  get testCaseType(): 'DEFVR' | 'DEACTION' | 'DESADETAIL' | 'APPVIEW' | 'CUSTOM' {
    return this.M.testCaseType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get rollbackTransaction(): boolean {
    return this.M.rollbackTransaction;
  }

  get cls(): string {
    return 'PSSysTestCaseImpl';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelObject' ||
      cls == 'IPSModelSortable' ||
      cls == 'IPSObject' ||
      cls == 'dataentity.IPSDataEntityObject' ||
      cls == 'testing.IPSDEActionTestCase' ||
      cls == 'testing.IPSDEFVRTestCase' ||
      cls == 'testing.IPSSysTestCase'
    )
      return true;
    return super.instanceof(cls);
  }
}
